# install 
git clone https://github.com/brendangregg/FlameGraph.git
ln -s /usr/local/src/FlameGraph/flamegraph.pl /usr/local/bin/flamegraph.pl
ln -s /usr/local/src/FlameGraph/stackcollapse-perf.pl /usr/local/bin/stackcollapse-perf.p
pid=$2;

if [ "$1" == "oncpu" ];then
	perf script -i perf_with_stack.data | stackcollapse-perf.pl | flamegraph.pl > perf.svg
fi

if [ "$1" == "offcpu" ];then
	perf script -i perf.data | stackcollapse-perf.pl | \
		flamegraph.pl --countname=ms --colors=io \
		--title="off-cpu Time Flame Graph" > perf.svg
fi

if [ "$1" == "java" ];then
	jstack -l $pid > tmp.txt;
	#之后将tmp.txt文件上传至 https://www.fastthread.io/，即可获得完整火焰图
fi

